#include<bits/stdc++.h>
using namespace std;
int di[10010],vi[10010],ai[10010];
int p[10010];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    cin>>t;
    while(t!=0){
        t--;
        int n,m,l,v,ou=0,nee=0,flag;
        cin>>n>>m>>l>>v;
        for(int i=1;i<=n;i++){
            cin>>di[i]>>vi[i]>>ai[i];
        }
        for(int i=1;i<=m;i++)cin>>p[i];
        for(int i=1;i<=n;i++){
            flag=0;
            for(int j=1;j<=m;j++){
                if(p[j]>=di[i]&&(vi[i]*vi[i]+2*ai[i]*(p[j]-di[i]))>0){
                    if(flag==0&&v*v<(vi[i]*vi[i]+2*ai[i]*(p[j]-di[i]))){
                    flag=1;
                    ou++;
                    }
                }
            }
        }
        cout<<ou<<" "<<endl;
    }
    return 0;
}
